package com.br.gvttv.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.br.gvttv.R;
import com.br.negocio.entidades.CanalTv;

public class GridCanaisBaseAdapter extends BaseAdapter {

	private List<CanalTv> canaTvList;
	private LayoutInflater mInflater;

	public GridCanaisBaseAdapter(Context context, List<CanalTv> canaTVList) {
		this.mInflater = LayoutInflater.from(context);
		this.canaTvList = canaTVList;
	}

	@Override
	public int getCount() {
		return canaTvList.size();
	}

	@Override
	public CanalTv getItem(int position) {
		return canaTvList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.canal_layout, null);
		}

		CanalTv canalTv = getItem(position);
		TextView canalTextView = (TextView) convertView.findViewById(R.id.canalTextView);

		canalTextView.setCompoundDrawablesWithIntrinsicBounds(0, canalTv.getDrawableLog(), 0, 0);
		canalTextView.setText(canalTv.getNumeroNome());

		return convertView;
	}
}
